package org.example;

import org.example.aop.SmartAnimalable;
import org.example.component.UserAction;
import org.example.component.UserDao;
import org.example.component.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        ApplicationContext ioc = new ClassPathXmlApplicationContext("beans.xml");
        UserAction userAction = ioc.getBean("userAction", UserAction.class);
        UserAction userAction2 = ioc.getBean("userAction", UserAction.class);
        UserService userService = ioc.getBean("userService", UserService.class);
        UserDao userDao = ioc.getBean("userDao", UserDao.class);

        System.out.println(userAction);
        System.out.println(userAction2);
        System.out.println(userDao);
        System.out.println(userService);

        userService.m1();

        //测试AOP
        SmartAnimalable smartDog = ioc.getBean(SmartAnimalable.class);
        smartDog.getSum(10,2);
    }
}